package reviewAlgorithms.doublePointers;

public class TwoSum {

    public static void main(String[] args) {

        int num = 1000000;
        System.out.println(twoSum(num));
    }

    private static boolean twoSum(int num) {
        if (num <= 0){
            return false;
        }
        int left = 0;
        int right = (int) Math.sqrt(num) + 1;
        int sum;
        while (left <= right){
            System.out.println(left + " " + right);
            sum = left * left + right * right;
            if (num > sum){
                left ++;
            }else if (num < sum){
                right --;
            }else {
                return true;
            }
        }
        return false;
    }
}
